<?php
class Organisation_model extends Med_model {

	// ----------------------------------- TABLE ANME
	const tableName="organisation";
	function getTableName(){
		return Organisation_model::tableName;
	}
	//------------------------------------ ATTRIBUTES
	var $name;
	var $contactName;
	var $adress;
	var $phone;
	var $cellPhone;
	var $workHours;
	var $priceDesc;
	var $mutuDesc;
	var $requestDelay;
	var $telPermanence;
	var $transportType;
	var $email;
	var $webSite;
	
	// ---------------------------------- CONSTRUCTOR
	function __construct(){
		parent::__construct();
	}
	// ----------------------------------- Public 

	function getOrganisationByZipCodes($zipFrom,$zipTo){
		
// 		$this->db->select("distinct org.* from meditravel.medi_organisation org
// 		join meditravel.medi_travel travOrg on travOrg.organisationFk=org.id
// 		join meditravel.medi_prov_links zipFromLinks on travOrg.zipFrom=zipFromLinks.code
// 		join meditravel.medi_prov_links zipToLinks on travOrg.zipTo=zipToLinks.code
// 		where zipFromLinks.zip='".$zipFrom."' and zipToLinks.zip= '".$zipTo."'",FALSE);
		
		
		$this->db->select("distinct org.* from meditravel.medi_organisation org
		join meditravel.medi_travel travOrg on travOrg.organisationFk=org.id
		where travOrg.zipFrom='".$zipFrom."' and travOrg.zipTo= '".$zipTo."'",FALSE);
		
		$query=$this->db->get();
		
		$arrayOrgs=array();
		foreach ($query->result(get_class($this)) as $row){
			$arrayOrgs[]=$row;
		}
		return $arrayOrgs;
		
	}

// 	select * from meditravel.medi_organisation org1 where org1.id in (  select distinct org.id from meditravel.medi_organisation org join meditravel.medi_travel travel on  org.id=travel.organisationFk
// 	where travel.zipFrom in ('6940','BEL','PLUX','NAM') and travel.zipTo in ('BEL','ALL','PLUX','NAM'))
}
